part of '../page.dart';

class _SingleWordBasePageTheme extends InheritedTheme {
  _SingleWordBasePageTheme({
    required Brightness brightness,
    required super.child,
  })  : _brightness = brightness,
        _data = _buildThemeData(
          brightness: brightness,
        );

  final Brightness _brightness;
  final _SingleWordBasePageThemeData _data;

  static _SingleWordBasePageThemeData _buildThemeData({
    required Brightness brightness,
  }) {
    return switch (brightness) {
      _ => _SingleWordBasePageThemeData.dark(),
    };
  }

  static _SingleWordBasePageThemeData of(BuildContext context) {
    final inheritedTheme = context.dependOnInheritedWidgetOfExactType<_SingleWordBasePageTheme>()!;
    return inheritedTheme._data;
  }

  @override
  Widget wrap(BuildContext context, Widget child) {
    final ancestorTheme = context.findAncestorWidgetOfExactType<_SingleWordBasePageTheme>();

    if (identical(this, ancestorTheme)) {
      return child;
    }

    return _SingleWordBasePageTheme(
      brightness: _brightness,
      child: child,
    );
  }

  @override
  bool updateShouldNotify(_SingleWordBasePageTheme oldWidget) {
    return _brightness != oldWidget._brightness;
  }
}

class _SingleWordBasePageThemeData {
  const _SingleWordBasePageThemeData._internal({
    required this.useCaseInputIconColor,
    required this.textTheme,
  });

  factory _SingleWordBasePageThemeData.dark() {
    return _SingleWordBasePageThemeData._internal(
      useCaseInputIconColor: CoreStyles.grey5,
      textTheme: _SingleWordBasePageTextTheme.dark(),
    );
  }

  final Color useCaseInputIconColor;
  final _SingleWordBasePageTextTheme textTheme;
}
